home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 2: CDPD 1 / Almathera Ten on Ten - Disc 2: CDPD 1.iso / pd / 051-075 / 061 / microemacs / hp110.c < prev    next >
C/C++ Source or Header  |  1995-03-13  |  4KB  |  231 lines

  1. /*
  2.  *    HP110:    Hewlett Packard 110 Screen Driver
  3.  */
  4.  
  5. #define    termdef    1            /* don't define "term" external */
  6.  
  7. #include        <stdio.h>
  8. #include    "estruct.h"
  9. #include        "edef.h"
  10.  
  11. #if     HP110
  12.  
  13. #define NROW    16                      /* Screen size.                 */
  14. #define NCOL    80                      /* Edit if you want to.         */
  15. #define    NPAUSE    100            /* # times thru update to pause */
  16. #define    MARGIN    8            /* size of minimim margin and    */
  17. #define    SCRSIZ    64            /* scroll size for extended lines */
  18. #define BEL     0x07                    /* BEL character.               */
  19. #define ESC     0x1B                    /* ESC character.               */
  20.  
  21. extern  int     ttopen();               /* Forward references.          */
  22. extern  int     ttgetc();
  23. extern  int     ttputc();
  24. extern  int     ttflush();
  25. extern  int     ttclose();
  26. extern  int     h110move();
  27. extern  int     h110eeol();
  28. extern  int     h110eeop();
  29. extern  int     h110beep();
  30. extern  int     h110open();
  31. extern    int    h110rev();
  32. extern    int    h110cres();
  33. extern    int    h110close();
  34. extern    int    h110kopen();
  35. extern    int    h110kclose();
  36.  
  37. #if    COLOR
  38. extern    int    h110fcol();
  39. extern    int    h110bcol();
  40.  
  41. int    cfcolor = -1;        /* current forground color */
  42. int    cbcolor = -1;        /* current background color */
  43. #endif
  44.  
  45. /*
  46.  * Standard terminal interface dispatch table. Most of the fields point into
  47.  * "termio" code.
  48.  */
  49. TERM    term    = {
  50.     NROW-1,
  51.         NROW-1,
  52.         NCOL,
  53.         NCOL,
  54.     MARGIN,
  55.     SCRSIZ,
  56.     NPAUSE,
  57.         h110open,
  58.         h110close,
  59.     h110kopen,
  60.     h110kclose,
  61.         ttgetc,
  62.         ttputc,
  63.         ttflush,
  64.         h110move,
  65.         h110eeol,
  66.         h110eeop,
  67.         h110beep,
  68.     h110rev,
  69.     h110cres
  70. #if    COLOR
  71.     , h110fcol,
  72.     h110bcol
  73. #endif
  74. };
  75.  
  76. #if    COLOR
  77. h110fcol(color)        /* set the current output color */
  78.  
  79. int color;    /* color to set */
  80.  
  81. {
  82.     if (color == cfcolor)
  83.         return;
  84.     ttputc(ESC);
  85.     ttputc('[');
  86.     h110parm(color+30);
  87.     ttputc('m');
  88.     cfcolor = color;
  89. }
  90.  
  91. h110bcol(color)        /* set the current background color */
  92.  
  93. int color;    /* color to set */
  94.  
  95. {
  96.     if (color == cbcolor)
  97.         return;
  98.     ttputc(ESC);
  99.     ttputc('[');
  100.     h110parm(color+40);
  101.     ttputc('m');
  102.         cbcolor = color;
  103. }
  104. #endif
  105.  
  106. h110move(row, col)
  107. {
  108.         ttputc(ESC);
  109.         ttputc('[');
  110.         h110parm(row+1);
  111.         ttputc(';');
  112.         h110parm(col+1);
  113.         ttputc('H');
  114. }
  115.  
  116. h110eeol()
  117. {
  118.         ttputc(ESC);
  119.         ttputc('[');
  120.     ttputc('0');
  121.         ttputc('K');
  122. }
  123.  
  124. h110eeop()
  125. {
  126. #if    COLOR
  127.     h110fcol(gfcolor);
  128.     h110bcol(gbcolor);
  129. #endif
  130.         ttputc(ESC);
  131.         ttputc('[');
  132.     ttputc('0');
  133.         ttputc('J');
  134. }
  135.  
  136. h110rev(state)        /* change reverse video state */
  137.  
  138. int state;    /* TRUE = reverse, FALSE = normal */
  139.  
  140. {
  141. #if    COLOR
  142.     int ftmp, btmp;        /* temporaries for colors */
  143. #endif
  144.  
  145.     ttputc(ESC);
  146.     ttputc('[');
  147.     ttputc(state ? '7': '0');
  148.     ttputc('m');
  149. #if    COLOR
  150.     if (state == FALSE) {
  151.         ftmp = cfcolor;
  152.         btmp = cbcolor;
  153.         cfcolor = -1;
  154.         cbcolor = -1;
  155.         h110fcol(ftmp);
  156.         h110bcol(btmp);
  157.     }
  158. #endif
  159. }
  160.  
  161. h110cres()    /* change screen resolution */
  162.  
  163. {
  164.     return(TRUE);
  165. }
  166.  
  167. h110beep()
  168. {
  169.         ttputc(BEL);
  170.         ttflush();
  171. }
  172.  
  173. h110parm(n)
  174. register int    n;
  175. {
  176.         register int q,r;
  177.  
  178.         q = n/10;
  179.         if (q != 0) {
  180.         r = q/10;
  181.         if (r != 0) {
  182.             ttputc((r%10)+'0');
  183.         }
  184.         ttputc((q%10) + '0');
  185.         }
  186.         ttputc((n%10) + '0');
  187. }
  188.  
  189. h110open()
  190. {
  191.     strcpy(sres, "15LINE");
  192.     revexist = TRUE;
  193.         ttopen();
  194. }
  195.  
  196. h110close()
  197.  
  198. {
  199. #if    COLOR
  200.     h110fcol(7);
  201.     h110bcol(0);
  202. #endif
  203.     ttclose();
  204. }
  205.  
  206. h110kopen()
  207.  
  208. {
  209. }
  210.  
  211. h110kclose()
  212.  
  213. {
  214. }
  215.  
  216. #if    FLABEL
  217. fnclabel(f, n)        /* label a function key */
  218.  
  219. int f,n;    /* default flag, numeric argument [unused] */
  220.  
  221. {
  222.     /* on machines with no function keys...don't bother */
  223.     return(TRUE);
  224. }
  225. #endif
  226. #else
  227. h110hello()
  228. {
  229. }
  230. #endif
  231.